﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using EasyStep.Data.Entities;
using EasyStep.Business.Interfaces;
using MahApps.Metro.Controls;
using WPF.TestEditor.Common.Interfaces;
using WPF.TestEditor.Properties;

namespace WPF.TestEditor
{
    public partial class ExecuteTestWindow : MetroWindow, ITestContextWindow
    {
        public ITestDataContext TestDataContext { get; set; }
        public TestInfo CurrentTest { get; set; }
        private bool quickStart;
        private IWebBrowserProxy[] StartupBrowsers;
        
        public ExecuteTestWindow(TestInfo data, ITestDataContext context, IWebBrowserProxy[] startupBrowsers, bool autoStart)
        {
            StartupBrowsers = startupBrowsers;           
            quickStart = autoStart;
            CurrentTest = data;
            TestDataContext = context;
            InitializeComponent();
            Loaded += new RoutedEventHandler(ExecuteTestWindow_Loaded);
            pnlExecute.ExecutionCompleted += new EventHandler(pnlExecute_ExecutionCompleted);
        }

        void pnlExecute_ExecutionCompleted(object sender, EventArgs e)
        {            
        }

        void ExecuteTestWindow_Loaded(object sender, RoutedEventArgs e)
        {
            pnlExecute.ReInit(CurrentTest, StartupBrowsers);
            this.Title ="Execute | "+System.IO.Path.GetFileName(Settings.Default.ActionsFolder.TrimEnd('\\'));
            if (quickStart)
                pnlExecute.RunTest();
        }
    }
}
